<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script src="d3.js"></script>
    <script>
        const svg = d3.select('body').append('svg');
        svg.attr('width',800);
        svg.attr('height',600);
        svg.style('border','2px solid #ccc');
        
        // 示例连接数据
        const data = [100,200,300,90,250,160] ;
        const pie = d3.pie().sort((a,b)=>d3.ascending(a,b)).padAngle(0.005);
        const arc = d3.arc().innerRadius(100).outerRadius(200) ;

        const colorScale = d3.scaleOrdinal(data,d3.schemeSet1);

        svg.append('g')
            .attr('transform','translate(400,300)')
            .selectAll('path')
            .data(pie(data))
            .join('path')
            .attr('stroke','#fff')
            .attr('d',arc)
            .attr('fill',d=>colorScale(d.data));

        svg.append('g')
            .attr('transform','translate(400,300)')
            .selectAll('text')
            .data(pie(data))
            .join('text')
            .attr('x',function(d){
                return arc.centroid(d)[0] ;
            })
            .attr('y',d=>arc.centroid(d)[1])
            .text(d=>d.data)
            .attr('text-anchor','middle')
            .attr('dominant-baseline','middle');

    </script>
    <text dominant-baseline="" text-anchor=""></text>
</body>
</html>